package sim;

public class Stichproben {
	
	SortableQueue customerQueu;
	
	public Stichproben() {
	}
	
	public long[] getTimesByIndex(int index){  //0 = arrival, 1 = initiaion, 2 = completion
		Customer[] customers = getCustomers();
		int length = customers.length;
		long[] acc = new long[length];
		for (int i = 0; i < length; i++) {
			acc[i] = getTimeByIndex(customers[i], index);
		}
		return acc;
	}
	
	private long getTimeByIndex(Customer customer, int index) {
		long acc = 0;
		if(index == 0){
			acc = customer.getArrivalTime();
		}
		else if(index == 1){
			acc = customer.getServiceInitiationTime();
		}
		else{
			acc = customer.getServiceCompletionTime();
		}
		return acc;
	}

	private Customer[] getCustomers(){
		int length = customerQueu.size();
		Customer[] customers = new Customer[length];
		for (int i = 0; i < length; i++) {
			Customer c = (Customer) customerQueu.popNextElement();
			customers[i] = c;
			customerQueu.pushNewElement(c);
		}
		return customers;
	}
	
	public void pushCustomer(Customer c){
		customerQueu.pushNewElement(c);
	}
	
	public void popCustomer(){
		customerQueu.popNextElement();
	}

}
